使用laravel-mix编译后打开页面报错如下:
Uncaught TypeError: Cannot read property 'csrfToken' of undefined
at Object.<anonymous> (app.3df1225….js:27701)
at __webpack_require__ (app.3df1225….js:20)
at Object.<anonymous> (app.3df1225….js:971)
at __webpack_require__ (app.3df1225….js:20)
at Object.<anonymous> (app.3df1225….js:27722)
at __webpack_require__ (app.3df1225….js:20)
at app.3df1225….js:66
at app.3df1225….js:69
按照github上作者的说法, 在view 中添加如下代码即可:
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
</script>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。